package mygame;

import java.util.ArrayList;

/**
 *
 * @author Xinchro
 */
public class Player {
    
    private String name;
    private int money;
    private int nextEXP;
    private int currentEXP;    
    private int upPoints;
    private float[] loc;
    private int invSize;
    private int level;
    private Pet activePet;
    ArrayList<Pet> pets;
    private Pet currentPet;
    int curPetNdx;
    Main main;
    int points;

    /*
     * Default constructor
     */
    public Player(Main main){
        name = "Player";
        money = 0;
        nextEXP = 0;
        currentEXP = 0;
        upPoints = 0;
	loc = new float[2];
	pets = new ArrayList<Pet>();
	loc[0] = 0;
	loc[1] = 0;
	curPetNdx = 0;
	this.main = main;
	points = 0;
    }   
    
    public void addPoint(){
	points+=1;
    }
    
    public void setLoc(float x, float y){
	loc[0] = x;
	loc[1] = y;
    }

    public float[] getLoc() {
	return loc;
    }
    
    public void setCurPet(Pet pet){
	currentPet = pet;
    }
    
    public Pet getCurPet(){
	return currentPet;
    }

    public void addPet(Pet pet){
	pets.add(pet);
    }
    
    public void swapNextPet(){
	if(curPetNdx < pets.size()-1){
	    curPetNdx += 1;
	}else{
	    curPetNdx = 0;
	    System.out.println("Hit end, going to 0");
    	}
	currentPet = pets.get(curPetNdx);
	System.out.println("Swapped to next pet " + currentPet.getName());
	putPetByPlayer();
    }
    
    public void swapPrevPet(){
	if(curPetNdx > 0){
	    curPetNdx -= 1;
	}else{
	    curPetNdx = pets.size()-1;
	    System.out.println("Hit beg, going to last");	    
    	}
	currentPet = pets.get(curPetNdx);
	System.out.println("Swapped to prev pet " + currentPet.getName());
	putPetByPlayer();
    }
    
    public void putPetByPlayer(){
	currentPet.setLoc(loc[0], loc[1]);
	currentPet.petModel.setLocalTranslation(main.playModel.getWorldTranslation());
    }
}
